const app = getApp()
const $ = app.globalData
Page({
	/**
	 * 页面的初始数据
	 */
	data: {
		onetablist:[],
		twoTabList:[],
		clickindex: 0,
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		var that = this
		var shoptype = $.shopstatr ? $.shoptype : 0
		wx.request({
			url: $.AdminUrl + "/YApi/getAllType",
			data: {
				shoptype:shoptype
			},
			success: function(data) {
				if(data.data.code){
					that.setData({
						onetablist:data.data.obj.oneTypeList,
						twoTabList:data.data.obj.twoTypeList,
					})
				}
				console.log(data);
				$.shopstatr = false
				console.log($.shopstatr)
			}
		})
	},
	// 获取点击的index
	liclick: function(e) {
		this.setData({
			clickindex: e.currentTarget.dataset['index']
		})
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {
		this.onLoad()
	},
	// 分类点击
	tabtwo:function(e){
		var tabone = this.data.onetablist[this.data.clickindex].id
		var tabtwo = e.currentTarget.dataset.id
		wx.navigateTo({
			url:"shoplist/shoplist?tabone="+tabone+"&tabtwo="+tabtwo
		})
	},
	// 分享转发
		onShareAppMessage: function() {
			var userinfo = wx.getStorageSync('userinfo')
			return {
				title: '优悦购生活管家',
				path: '/pages/index/index?userid='+userinfo.loginname,
				success: (res) => {
					console.log("转发成功", res);
				},
				fail: (res) => {
					console.log("转发失败", res);
				}
			}
		}
})
